package com.llg.controller;

import com.llg.model.response.DataResult;
import com.llg.model.response.PageResult;
import com.llg.model.response.ResponseResult;
import com.llg.pojo.SupplyBrand;
import com.llg.service.SupplyBrandService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("/supplyBrand")
public class SupplyBrandController {

    @Autowired
    private SupplyBrandService supplyBrandService;

    //查询所有电源品牌
    @GetMapping("/findAll")
    public PageResult<SupplyBrand> findAll(){
        return supplyBrandService.findAll();
    }

    //搜索并分页查询
    @PostMapping("/findList")
    public PageResult<SupplyBrand> findList(Integer currentPage,Integer pageSize,@RequestBody SupplyBrand supplyBrand){
        return supplyBrandService.findList(currentPage, pageSize, supplyBrand);
    }

    //通过id查
    @GetMapping("/{id}")
    public DataResult<SupplyBrand> findById(@PathVariable("id") Integer id){
        return supplyBrandService.findById(id);
    }

    //增
    @PostMapping("/add")
    public DataResult<SupplyBrand> add(@RequestBody SupplyBrand supplyBrand){
        return supplyBrandService.add(supplyBrand);
    }

    //删
    @GetMapping("/delete/{id}")
    public ResponseResult delete(@PathVariable Integer id){
        return supplyBrandService.delete(id);
    }

    //改
    @PostMapping("/update")
    public ResponseResult update(@RequestBody SupplyBrand supplyBrand) {
        return supplyBrandService.update(supplyBrand);
    }
}
